package com.levi.config;

import com.levi.interceptor.LogInterceptor;
import com.levi.interceptor.MDCInterceptor;
import com.levi.interceptor.UriInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author shentong
 * @since 2022/3/8 10:01 PM
 */
@Configuration
public class MvcConfig implements WebMvcConfigurer {

	@Autowired
	private UriInterceptor uriInterceptor;

	@Autowired
	private LogInterceptor logInterceptor;

	@Autowired
	private MDCInterceptor mdcInterceptor;

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		// 配置该拦截器对哪些路径进行拦截
		registry.addInterceptor(uriInterceptor).addPathPatterns("/test/*");
		//registry.addInterceptor(logInterceptor).excludePathPatterns("/login");
		registry.addInterceptor(mdcInterceptor).excludePathPatterns("/login");
	}

}
